<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="contest/contest-nav"}
    <br/>
    <div class="div_contest_pagination" style="text-align: center">
        <ul class="contest_pagination modal-1">
            {foreach name="all_problem_link" item="v"}
            <li> <a href="{:url('web/contest/problem',['cid'=>$cid,'num'=>$v['num']])}" {if condition="$v['num']==$num" } style="border-color: #4285F4;background: #4285F4;color: #fff;" {/if}>{$v['num']}</a></li>
            {/foreach}
        </ul>
        <br>
    </div>
    <hr/>
    <div class="layui-row layui-col-space15" style="margin-left: 30px;margin-right: 30px;">
        <div style="margin-bottom: 0;">
            <ul style="text-align: center;">
                <h1>
              {$num}
              {$problemitem.title}</h1>
            </ul>
            <br/>
            <ul style="text-align: center;">
                <span class="layui-badge layui-bg-orange">内存限制:{$problemitem.memory_limit}MB</span>
                <span class="layui-badge">时间限制:{$problemitem.time_limit}s</span>
                <span class="layui-badge layui-bg-blue">Special Judge:
              {eq name='problemitem.spj' value='0'}No{else/}Yes{/eq}
              </span>
            </ul>
            <br/>
        </div>
        <br/>
        <!--<div class="fly-panel" style="margin-bottom: 0;">
            <ul class="submit-btn-comb">   
                <a href="<?php if($is_login) echo url('web/Problem/submit'); else echo url('web/User/UserLogin'); ?>" class="layui-btn layui-btn-normal">提交代码</a>
            </ul>
        </div> <br/>-->
        <div  style="margin-bottom: 0;">
            <div class="nyoj-problem-content">
                <h2 class="nyoj-problem-content-title">题目描述:</h2>
                <div class="nyoj-problem-content-col nyoj-clear-width">
                    {$problemitem.description}
                </div>
            </div>
        </div>
         <div class="fly-panel" style="margin-bottom: 0;">
                        <div class="nyoj-problem-content">
                            <h2 class="nyoj-problem-content-title">输入描述:</h2>
                            <div class="nyoj-problem-content-col nyoj-clear-width">
                                <pre class='nyoj-pre-clear'>{:htmlspecialchars($problemitem.input)}</pre>
                            </div>
                        </div>
                    </div>
                    <div class="fly-panel" style="margin-bottom: 0;">
                        <div class="nyoj-problem-content">
                            <h2 class="nyoj-problem-content-title">输出描述:</h2>
                            <div class="nyoj-problem-content-col nyoj-clear-width">
                                <pre class='nyoj-pre-clear'>{:htmlspecialchars($problemitem.output)}</pre>
                            </div>
                        </div>
                    </div>
                    <div class="fly-panel" style="margin-bottom: 0;">
                        <div class="nyoj-problem-content" >
                            <h2 class="nyoj-problem-content-title">样例输入:</h2>
                            <div class="nyoj-problem-content-col nyoj-clear-width" style="padding: 10px;">
                                <button  class="cpoy-btn" onclick="copyToClipboard()" id="input-button">复制</button>
                                <pre id="input-box" lay-encode="true">{:htmlspecialchars($problemitem.sample_input)}</pre>
                            </div>
                        </div>
                    </div>
                    <div class="fly-panel" style="margin-bottom: 0;">
                        <div class="nyoj-problem-content" >
                            <h2 class="nyoj-problem-content-title">样例输出:</h2>
                            <div class="nyoj-problem-content-col nyoj-clear-width" style="padding: 10px;">
                                <pre lay-encode="true">{:htmlspecialchars($problemitem.sample_output)}</pre>
                            </div>
                        </div>
                    </div>
        <div  style="margin-bottom: 0;">
            <div class="nyoj-problem-content">
                <h2 class="nyoj-problem-content-title">提示:</h2>
                <div class="nyoj-problem-content-col nyoj-clear-width">
                    {$problemitem.hint?$problemitem.hint:'没有提示哦'}
                </div>
            </div>
        </div>
        <div  style="margin-bottom: 0;">
            <div class="nyoj-problem-content">
                <h2 class="nyoj-problem-content-title">来源:</h2>
                <div class="nyoj-problem-content-col nyoj-clear-width">
                    {$problemitem.source?$problemitem.source:'nyoj'}
                </div>
            </div>
        </div>
        <div style="margin-bottom: 0;">
            <ul class="submit-btn-comb">
                <a class="layui-btn" id="submit-code" nyoj-cid="{$list[0]['contest_id']}" nyoj-pid="{$problemitem.problem_id}">代码提交</a>
            </ul>
        </div>
        <!--     -->
    </div>
    </div>
    </div>
    {include file="public/foot"}
</body>
<script>
layui.use(['element', 'jquery', 'form', 'layer'], function() {
    // console.log('abcdef');
    var element = layui.element;
    var $ = layui.jquery;
    var form = layui.form;
    var layer = layui.layer;
    form.on('submit(delete)', function(data) {
        if (data.field.tag === undefined) {
            layer.msg('请先选中题目分类');
            return false;
        }
        $.ajax({
            url: "{:url('web/problem/tag_delete')}",
            type: 'post',
            data: data.field,
            dataType: "JSON",
            success: function(res) {
                // console.log(res);

                if (res.result === 0) {
                    layer.msg(res.msg);
                    setTimeout("parent.location.reload()", 1000);
                } else {
                    layer.msg(res.msg);
                }
            },
            error: function() {
                layer.msg('进入后台失败~');
            }
        });
        return false;
    });
    form.on('submit(add)', function(data) {
        if (data.field.tag_level_1 === undefined || data.field.tag_level_1 < 0) {
            layer.msg('请先选择分类');
            return false;
        }
        // console.log(data.field);
        $.ajax({
            url: "{:url('web/problem/tag_add')}",
            type: 'post',
            data: data.field,
            dataType: "JSON",
            success: function(res) {

                if (res.result === 0) {
                    // console.log("tag_id="+res.tag_id);
                    layer.msg(res.msg);
                    setTimeout("parent.location.reload()", 1000);
                } else {
                    layer.msg(res.msg);
                }
            },
            error: function() {
                layer.msg('进入后台失败~');
            }
        });
        return false;
    });
    form.on('select(test1)', function(data) {
        // console.log(data.value);
        $.ajax({
            url: "{:url('web/problem/get_tag1_id')}",
            type: 'post',
            data: { 'tid': data.value },
            dataType: "JSON",
            success: function(res) {
                // layer.msg('获取数据成功');
                // console.log(res);
                $('#tag_level_2 option:gt(0)').remove();
                $('#tag_level_3 option:gt(0)').remove();
                $.each(res, function(i, item) {
                    $("<option value=" + item.tag_id + ">" + item.tag_name +
                        "</option>").appendTo($('#tag_level_2'));
                });
                form.render('select');
            },
            error: function() {
                layer.msg('页面进入后台失败');
            }
        });
    });
    form.on('select(test2)', function(data) {
        // console.log(data.value);
        $.ajax({
            url: "{:url('web/problem/get_tag2_id')}",
            type: 'post',
            data: { 'tid': data.value },
            dataType: "JSON",
            success: function(res) {
                // layer.msg('获取数据成功');
                $('#tag_level_3 option:gt(0)').remove();
                $.each(res, function(i, item) {
                    $("<option value=" + item.tag_id + ">" + item.tag_name +
                        "</option>").appendTo($('#tag_level_3'));
                });
                form.render('select');
            },
            error: function() {
                layer.msg('页面进入后台失败');
            }
        });
    });
});
</script>
{include file="public/submit-js"}
<script>
layui.use(['jquery', 'layer'], function() {
    var $ = layui.jquery;
    var layer = layui.layer;
    var content = $("#input-box").text();
    var clipboard = new ClipboardJS('#input-button', {
        text: function() {
            return content;
        }
    });
    clipboard.on('success', function(e) {
        layer.msg('复制成功');
    });

    clipboard.on('error', function(e) {
        layer.msg('您的浏览器不支持复制哦~');
        console.log(e);
    });
});
</script>

</html>